import cv2 as cv
import numpy as np

import matplotlib
import matplotlib.pyplot as plt
#设置字体为楷体
matplotlib.rcParams['font.sans-serif'] = ['KaiTi']
# 1 读取图像
img = cv.imread('../../imgs/1.jpg', 0)

# 2 laplacian转换
result = cv.Laplacian(img,cv.CV_16S)
Scale_abs = cv.convertScaleAbs(result)
# 3 图像展示
plt.figure(figsize=(10,8),dpi=100)
plt.subplot(121),plt.imshow(img,cmap=plt.cm.gray),plt.title('原图')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(Scale_abs,cmap = plt.cm.gray),plt.title('Laplacian检测后结果')
plt.xticks([]), plt.yticks([])
plt.show()